package Shape;

interface Shape{
    double getArea();
    double getPerimeter();
}

class MyRectangle implements Shape{
    private double width,height;
    public MyRectangle(double w,double h){
        width = w;
        height = h;
    }
    public double getArea(){
        return width*height;
    }
    public double getPerimeter(){
        return (width+height)*2;
    }
    void toString1(){
        System.out.println("width = "+width+",height = "+height+",perimeter = "+getPerimeter()+
                ",area = "+getArea());
    }
}

class MyTriangle implements Shape{
    private double a,b,c,s;
    public MyTriangle(double x,double y,double z){
        a = x;
        b = y;
        c = z;
        s = (x+y+z)/2;
    }
    public double getArea(){
        return Math.sqrt(s*(s-a)*(s-b)*(s-c));
    }
    public double getPerimeter(){
        return a+b+c;
    }
    void toString1(){
        System.out.println("three sides: "+a+","+b+","+c+",perimeter = "+getPerimeter()+
                ",area = "+getArea());
    }
}

public class Test {
    public static void main(String[] args){
        MyRectangle r = new MyRectangle(4,5);
        r.toString1();
        MyTriangle t = new MyTriangle(3,4,5);
        t.toString1();
    }
}
